<template>
	<view>
		<page-head title="毕业证查询"></page-head>
		
		<view class="uni-flex uni-row" v-if="content">
			<view class="text" style="width: 200upx;">姓名：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{content}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="sex">
			<view class="text" style="width: 200upx;">性别：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{sex}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="idcard">
			<view class="text" style="width: 200upx;">身份证：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{idcard}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="adddate">
			<view class="text" style="width: 200upx;">发证日期：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{data}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="title">
			<view class="text" style="width: 200upx;">证书编号：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{title}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="classid">
			<view class="text" style="width: 200upx;">文化程度：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">大专</view>
		</view>

		<view class="uni-flex uni-row" v-if="classid">
			<view class="text" style="width: 200upx;">专业名称：</view>
			<view class="text" style="-webkit-flex: 1;flex: 1;">{{classid}}</view>
		</view>
		
		<view class="uni-flex uni-row" v-if="pic">
			<image :src="pic" mode="aspectFit" style="width: 100%;"></image>
		</view>
		
		<view v-if="formHide" class="uni-padding-wrap">
			<form @submit="formSubmit">
				<view class="uni-form-item uni-column inputsytle">
					<input class="uni-input" v-model="sfzh" name="sfzh" placeholder="请输入身份证号" />
				</view>
				<view class="uni-btn-v inputsytle">
					<button type="primary" form-type="submit">提交</button>
				</view>
			</form>
		</view>
	</view>
</template>
<script>
	//来自 graceUI 的表单验证， 使用说明见手册 http://grace.hcoder.net/doc/info/73-3.html
	var  graceChecker = require("../../common/graceChecker.js")
	export default {
		data() {
			return {
				content: '',
				sex: '',
				yxdm: '',
				data: '',
				sfzh: '',
				sfzh1: '',
				idcard: '',
				adddate: '',
				title: '',
				classid: '',
				pic: '',
				formHide: true,
				xh: '',
				xm: '',
				ksh:'',
				xh: '',
				xb: '',
				zymc:'',
				bh: ''
			}
		},
		methods: {
			getXueJi(){
				uni.request({
					url:'https://www.hngsxy.com/mybatisplus/gsxyZsTableCopy/findGsxyZsTableCopyOne',
					// url:'http://localhost/gsxyZsTableCopy/findGsxyZsTableCopyOne',
					data:{
						sfzh: this.sfzh
					},
					success: (res) => {
						if(res.data){
							uni.showToast({title:"查到了", icon:"none"})
							this.formHide = false
							this.content = res.data.content
							// this.xh = res.data.sex
							if(res.data.sex === '1'){
								this.sex = '男'
							}else{
								this.sex = '女'
							}
							this.idcard = res.data.idcard
							this.data = res.data.data
							this.adddate  = res.data.adddate
							this.title = res.data.title
							this.pic = res.data.pic
							
							// if(res.res.data.classid ==== '11'){
							// 	this.classid = '计算机应用技术'
							// }
						if(res.data.classid === '11'){
							this.classid = '计算机应用技术'
						}else if(res.data.classid === '12'){
							this.classid = '机电一体化'
						}else if(res.data.classid === '13'){
							this.classid = '机械制造与自动化'
						}else if(res.data.classid === '14'){
							this.classid = '模具设计与制造'
						}else if(res.data.classid === '15'){
							this.classid = '汽车运用技术'
						}else if(res.data.classid === '16'){
							this.classid = '工程监理'
						}else if(res.data.classid === '17'){
							this.classid = '房屋建筑工程'
						}else if(res.data.classid === '18'){
							this.classid = '室内装潢设计'
						}else if(res.data.classid === '19'){
							this.classid = '应用电子技术'
						}else if(res.data.classid === '20'){
							this.classid = '工商企业管理'
						}else if(res.data.classid === '21'){
							this.classid = '财务会计'
						}else if(res.data.classid === '22'){
							this.classid = '市场营销'
						}else if(res.data.classid === '23'){
							this.classid = '广告设计与制作'
						}else if(res.data.classid === '24'){
							this.classid = '旅游酒店管理'
						}else if(res.data.classid === '25'){
							this.classid = '机械设计制造及自动化'
						}else if(res.data.classid === '26'){
							this.classid = '电子工程'
						}else if(res.data.classid === '27'){
							this.classid = '房屋建筑工程'
						}else if(res.data.classid === '28'){
							this.classid = '计算机及应用'
						}else if(res.data.classid === '29'){
							this.classid = '计算机信息管理'
						}else if(res.data.classid === '31'){
							this.classid = '工业管理工程'
						}else if(res.data.classid === '32'){
							this.classid = '法律'
						}else if(res.data.classid === '33'){
							this.classid = '会计'
						}else if(res.data.classid === '34'){
							this.classid = '外贸英语'
						}else if(res.data.classid === '35'){
							this.classid = '美术'
						}else if(res.data.classid === '36'){
							this.classid = '汽车运用技术'
						}else if(res.data.classid === '37'){
							this.classid = '汽车运用工程'
						}else if(res.data.classid === '38'){
							this.classid = '机电一体化工程'
						}else if(res.data.classid === '39'){
							this.classid = '房屋建筑工程及设计'
						}else if(res.data.classid === '40'){
							this.classid = '英语'
						}else if(res.data.classid === '41'){
							this.classid = '工商管理'
						}else if(res.data.classid === '42'){
							this.classid = '国际贸易'
						}else if(res.data.classid === '43'){
							this.classid = '电子技术'
						}else if(res.data.classid === '44'){
							this.classid = '临床医学'
						}

						}else{
							uni.showToast({title:"查无此人", icon:"none"})
						}
					},
					fail: (res) => {
						console.log("未知错误")
					}
				})
			},
			formSubmit: function(e) {
				let rule = [
					{name:"sfzh", checkType : "string", checkRule:"18,18",  errorMsg:"请输入正确的身份证号码"}
				]
				//进行表单检查
				let formData = e.detail.value
				let checkRes = graceChecker.check(formData, rule)
				if(checkRes){
					this.getXueJi()
					// uni.showToast({title:"验证通过!", icon:"none"})
				}else{
					uni.showToast({ title: graceChecker.error, icon: "none" })
				}
			}
		}
	}
</script>

<style>
	.uni-form-item .title {
		padding: 20rpx 0;
	}
	.inputsytle{
		padding: 10rpx;
	}
	.flex-item {
		width: 33.3%;
		height: 200upx;
		text-align: center;
		line-height: 200upx;
	}

	.flex-item-V {
		width: 100%;
		height: 150upx;
		text-align: center;
		line-height: 150upx;
	}

	.text {
		margin: 15upx 10upx;
		padding: 0 20upx;
		background-color: #ebebeb;
		height: 70upx;
		line-height: 70upx;
		text-align: center;
		color: #777;
		font-size: 26upx;
		color: #000000;
	}

	.desc {
		/* text-indent: 40upx; */
	}
</style>
